package shopping.demo.util;

import java.util.concurrent.atomic.AtomicInteger;

public class OrderIdUtils {
    private static AtomicInteger ORDER_PREFIX = new AtomicInteger(1000);
    private static final String USER_PREFIX = "U";
    private static final String GOODS_PREFIX = "G";

    public static final Integer CREATED = 0;
    public static final Integer COMMIT = 1;
    public static final Integer FINISHED = 2;

    public static String getOrderId(Long uid, Integer gid) {
        String orderId = ORDER_PREFIX.getAndIncrement() + USER_PREFIX + uid + GOODS_PREFIX + gid;
        return orderId;
    }
}
